﻿//
// (C) Copyright 2009 Irantha Suwandarathna (irantha@gmail.com)
// All rights reserved.
//

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using EffiProzDB;
using EffiProzDB.Lib;
using EffiProzDB.Persist;


namespace EffiProzDBTest.SelfTest 
{
    /// <summary>
    /// Summary description for TestMainScript
    /// </summary>
    [TestClass]
    public class TestMainScript :BaseTest
    {
      
        string testScriptPath = "../../../EffiProzDBTest/SelfTest/Scripts/";


        public TestMainScript() : base()
        {
       
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion


        [TestMethod]
        public void CreateSampleDB()
        {
            lock (this)
            {
                CleanUp("SampleDB");
                SessionInterface sessionProxy2 = DatabaseManager.newSession(DatabaseURL.S_FILE, dataPath + "SampleDB",
    user, password, props);
                string scriptPath = testScriptPath + "SampleDB.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }

        }

        [TestMethod]
        public void TestSelf()
        {
            lock (this)
            {
                CleanUp("TestSelfMain");
                SessionInterface sessionProxy2 = DatabaseManager.newSession(DatabaseURL.S_FILE, dataPath + "TestSelfMain",
    user, password, props);
                string scriptPath = testScriptPath + "TestSelf.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
           
        }

        [TestMethod]
        public void TestSelfAlterTable()
        {
            lock (this)
            {
                string scriptPath = testScriptPath + "TestSelfAlterTable.txt";
                TestUtil.testScript(sessionProxy, scriptPath);
            }

        }

        [TestMethod]
        public void TestSelfAlterColumn()
        {
            lock (this)
            {
                string scriptPath = testScriptPath + "TestSelfAlterColumn.txt";
                TestUtil.testScript(sessionProxy, scriptPath);
            }

        }

        [TestMethod]
        public void TestSelfCasewhen()
        {
            lock (this)
            {
                string scriptPath = testScriptPath + "TestSelfCasewhen.txt";
                TestUtil.testScript(sessionProxy, scriptPath);
            }

        }

        [TestMethod]
        public void TestSelfCheckConstraints()
        {
            lock (this)
            {
                string scriptPath = testScriptPath + "TestSelfCheckConstraints.txt";
                TestUtil.testScript(sessionProxy, scriptPath);
            }

        }

        [TestMethod]
        public void TestSelfConversions()
        {
            lock (this)
            {
                string scriptPath = testScriptPath + "TestSelfConversions.txt";
                TestUtil.testScript(sessionProxy, scriptPath);
            }

        }

        [TestMethod]
        public void TestSelfCreate()
        {
            lock (this)
            {
                CleanUp("TestSelfCreate");
                SessionInterface sessionProxy2 = DatabaseManager.newSession(DatabaseURL.S_FILE, dataPath + "TestSelfCreate",
    user, password, props);

                string scriptPath = testScriptPath + "TestSelfCreate.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }

        }

        [TestMethod]
        public void TestSelfFieldLimits()
        {
            lock (this)
            {
                HsqlProperties props2 = new HsqlProperties();
                props2.setProperty(HsqlDatabaseProperties.sql_enforce_strict_size, true);

                CleanUp("TestFieldLimits");
                SessionInterface sessionProxy2 = DatabaseManager.newSession(DatabaseURL.S_FILE, dataPath + "TestFieldLimits",
    user, password, props2);

                string scriptPath = testScriptPath + "TestSelfFieldLimits.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }

        }


        [TestMethod]
        public void TestSelfFKModes()
        {
            lock (this)
            {
                CleanUp("TestSelfFKModes");
                SessionInterface sessionProxy2 = DatabaseManager.newSession(DatabaseURL.S_FILE, dataPath + "TestSelfFKModes",
    user, password, props);

                string scriptPath = testScriptPath + "TestSelfFKModes.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }

        }

        [TestMethod]
        public void TestSelfGrantees()
        {
            lock (this)
            {
                CleanUp("TestSelfGrantees");
                SessionInterface sessionProxy2 = DatabaseManager.newSession(DatabaseURL.S_FILE, dataPath + "TestSelfGrantees",
    user, password, props);
                string scriptPath = testScriptPath + "TestSelfGrantees.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }

        }

        [TestMethod]
        public void TestSelfGroupBy()
        {
            lock (this)
            {
                string scriptPath = testScriptPath + "TestSelfGroupBy.txt";
                TestUtil.testScript(sessionProxy, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfInPredicateReferencing()
        {
            lock (this)
            {
                string scriptPath = testScriptPath + "TestSelfInPredicateReferencing.txt";
                TestUtil.testScript(sessionProxy, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfInsertDeleteQueries()
        {
            lock (this)
            {
                CleanUp("TestSelfInsertDeleteQueries");
                SessionInterface sessionProxy2 = DatabaseManager.newSession(DatabaseURL.S_FILE, dataPath + "TestSelfInsertDeleteQueries",
    user, password, props);

                string scriptPath = testScriptPath + "TestSelfInsertDeleteQueries.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfIssues()
        {
            lock (this)
            {
                string scriptPath = testScriptPath + "TestSelfIssues.txt";
                TestUtil.testScript(sessionProxy, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfJoins()
        {
            lock (this)
            {
                string scriptPath = testScriptPath + "TestSelfJoins.txt";
                TestUtil.testScript(sessionProxy, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfLeftJoin()
        {
            lock (this)
            {
                string scriptPath = testScriptPath + "TestSelfLeftJoin.txt";
                TestUtil.testScript(sessionProxy, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfMultiGrants()
        {
            lock (this)
            {
                string scriptPath = testScriptPath + "TestSelfMultiGrants.txt";
                TestUtil.testScript(sessionProxy, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfNameResolution()
        {
            lock (this)
            {
                string scriptPath = testScriptPath + "TestSelfNameResolution.txt";
                TestUtil.testScript(sessionProxy, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfNameResolutionSchemas()
        {
            lock (this)
            {
                SessionInterface sessionProxy2 = DatabaseManager.newSession(connType, "ResolutionSchemas",
      user, password, props);
                string scriptPath = testScriptPath + "TestSelfNameResolutionSchemas.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfNot()
        {
            lock (this)
            {
                SessionInterface sessionProxy2 = DatabaseManager.newSession(connType, "SelfNot",
        user, password, props);
                string scriptPath = testScriptPath + "TestSelfNot.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfPrimaryKeys()
        {
            lock (this)
            {
                CleanUp("PrimaryKeys");
                SessionInterface sessionProxy2 = DatabaseManager.newSession(DatabaseURL.S_FILE, "PrimaryKeys",
           user, password, props);
                string scriptPath = testScriptPath + "TestSelfPrimaryKeys.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfQueries()
        {
            lock (this)
            {
                CleanUp("Queries");
                SessionInterface sessionProxy2 = DatabaseManager.newSession(DatabaseURL.S_FILE, "Queries",
             user, password, props);
                string scriptPath = testScriptPath + "TestSelfQueries.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfRightCaching()
        {
            SessionInterface sessionProxy2 = DatabaseManager.newSession(connType, "RightCaching",
          user, password, props); 
            string scriptPath = testScriptPath + "TestSelfRightCaching.txt";
            TestUtil.testScript(sessionProxy2, scriptPath);
        }

        [TestMethod]
        public void TestSelfRoleNesting()
        {
            lock (this)
            {
                SessionInterface sessionProxy2 = DatabaseManager.newSession(connType, "RoleNesting",
               user, password, props);
                string scriptPath = testScriptPath + "TestSelfRoleNesting.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfSubselects()
        {
            lock (this)
            {
                SessionInterface sessionProxy2 = DatabaseManager.newSession(connType, "Subselects",
               user, password, props);
                string scriptPath = testScriptPath + "TestSelfSubselects.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfSysTables()
        {
            lock (this)
            {
                SessionInterface sessionProxy2 = DatabaseManager.newSession(connType, "SysTables",
               user, password, props);
                string scriptPath = testScriptPath + "TestSelfSysTables.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfTransaction()
        {
            lock (this)
            {
                CleanUp("TestSelfTransaction");
                SessionInterface sessionProxy2 = DatabaseManager.newSession(DatabaseURL.S_FILE, "TestSelfTransaction",
               user, password, props);
                string scriptPath = testScriptPath + "TestSelfTransaction.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfUnions()
        {
            lock (this)
            {
                SessionInterface sessionProxy2 = DatabaseManager.newSession(connType, "TestSelfUnions",
               user, password, props);
                string scriptPath = testScriptPath + "TestSelfUnions.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfUserFunction()
        {
            lock (this)
            {
                SessionInterface sessionProxy2 = DatabaseManager.newSession(connType, "UserFunction",
               user, password, props);
                string scriptPath = testScriptPath + "TestSelfUserFunction.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfViews()
        {
            lock (this)
            {
                CleanUp("TestSelfViews");
                SessionInterface sessionProxy2 = DatabaseManager.newSession(DatabaseURL.S_FILE, "TestSelfViews",
               user, password, props);
                string scriptPath = testScriptPath + "TestSelfViews.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }

        [TestMethod]
        public void TestSelfViewSchemaResolve()
        {
            lock (this)
            {
                SessionInterface sessionProxy2 = DatabaseManager.newSession(connType, "ViewSchemaResolve",
               user, password, props);
                string scriptPath = testScriptPath + "TestSelfViewSchemaResolve.txt";
                TestUtil.testScript(sessionProxy2, scriptPath);
            }
        }


    }
}
